(import
  (except (rnrs base) let-values)
  (only (guile)
        lambda* λ
        error
        eof-object?
        simple-format
        current-output-port
        call-with-output-string
        )
  (prefix (logging) log:)
  (ice-9 binary-ports)
  (ice-9 textual-ports)
  (ice-9 peg)
  (ice-9 pretty-print)
  (print-utils)
  (peg-tree-utils)
  (file-reader)
  (random-utils)
  (prefix (lf2-data-crypt) lf2crypt:)
  (prefix (grammar) grammar:)
  (prefix (srfi srfi-1) srfi-1:))


(define shuffle-phases
  (λ (stage-data)
    ""))


(define main
  (λ ()
    (let* ([loc "data/stage.dat"]
           [stage-text
            (process-file loc lf2crypt:decrypt)]
           [stage-data
            (peg:tree (match-pattern grammar:STAGE-DAT stage-text))]
           [survival-data
            (find-in-peg-tree stage-data 'SURVIVAL-STAGE)]
           [phases
            (flatten-filter-peg-tree (find-all-in-peg-tree survival-data 'PHASE) 'PHASE)])
      (print-limited stage-text #:max 1024)
      ;; (print-limited stage-data #:max 1024)
      ;; (print-limited survival-data #:max 512)
      (print-limited (fisher-yates-shuffle phases)
                     #:max 2048))))

(main)
